﻿CREATE VIEW [acms].[Post_View]
AS 
	SELECT 
		a.Id,
		a.SiteId,
		c.Name as SiteName,
		d.Id as VersionId,
		d.ParentId,
		d.ParentPath as ParentPath,
		d.Name,
		d.DisplayName,
		d.ThumbnailId,
		d.TemplateId,
		b.Name as TemplateName,
		d.Summary,
		d.Tags,
		d.Sequence,
		d.ParentSequence,
		a.Created as PostCreated,
		d.Created as VersionCreated,
		d.StartDate,
		d.EndDate,
		d.ConcurencyId
	FROM [acms].[Posts] a
		inner join [acms].[Sites] c on a.SiteId = c.Id
		inner join [acms].[PostVersions] d on a.Id = d.PostId
		inner join [acms].[Templates] b on d.TemplateId = b.Id 
	WHERE a.Deleted = 0
		and b.Deleted = 0
;